package com.sky.product.controller;

import com.sky.api.domain.entity.Dish;
import com.sky.common.constant.StatusConstant;
import com.sky.common.result.Result;

import com.sky.api.domain.vo.DishVO;
import com.sky.product.service.DishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userDishController")
@RequestMapping("/user/dish")
@Slf4j
@Api(tags = "C端-菜品浏览接口")
public class UserDishController {

    @Autowired
    private DishService dishService;

    /**
     * 根据分类id查询菜品列表,其中包含了口味列表
     *
     * @param categoryId 分类id
     * @return 菜品列表
     * */
    @GetMapping("/list")
    @ApiOperation("根据分类id查询菜品列表")
    public Result<List<DishVO>> list(Long categoryId){
        log.info("根据分类id{} 查询菜品列表", categoryId);
        final Dish dish = new Dish();
        dish.setCategoryId(categoryId);
        dish.setStatus(StatusConstant.ENABLE);  // 查询起售的菜品

        List<DishVO> list = dishService.listWishFlavor(dish);

        return Result.success(list);
    }
}
